package com.lz.rocketmq.consumer.project.listener.exception;

import com.lz.rocketmq.consumer.common.utils.DateUtils;
import org.apache.rocketmq.spring.annotation.MessageModel;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

/**
 * 异常重试
 *
 * @author Administrator
 */
@Service
@RocketMQMessageListener(consumerGroup = "e1", topic = "market-topic", messageModel = MessageModel.CLUSTERING)
public class ConsumerExpE1Service implements RocketMQListener<String> {
    private static final Logger logger = LoggerFactory.getLogger(ConsumerExpE1Service.class);

    public static int t = 1;

    @Override
    public void onMessage(String message) {
        try {
            //测试时打开
            //double a = 1 / 0;
            System.out.println(String.format("日期: %s Service:%s group: %s topic: %s messageModel:%s msg:%s", DateUtils.getCurr_YYYY_MM_DD_HH_MM_SS_SSS(), "ExpE1", "e1", "market-topic", "广播", message));

        } catch (Exception e) {
            logger.error("ExpE1 异常重试：" + (t++));
            throw e;
        }
    }

}